package br.com.ps.bombertournament.game.scene;

import br.com.ps.bombertournament.game.Game;

import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;

public abstract class BaseScene implements ApplicationListener {

	private Game game;
	private OrthographicCamera camera;

	private SpriteBatch spriteBatch;
	
	public void create() {
		game = new Game();
		spriteBatch = new SpriteBatch();
	}

	public void resume() {
		game.resume();
	}

	public void resize(int width, int height) {
		game.resize(width, height);
	}

	public void pause() {
		game.pause();
	}

	public void dispose() {
		game.dispose();
	}

	public void render() {
		GL10 gl = Gdx.graphics.getGL10();
		camera.update();
        camera.apply(gl);
        spriteBatch.setProjectionMatrix(camera.combined);

		gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
        
        spriteBatch.begin();
        
		game.update(Gdx.graphics.getDeltaTime());
		
		game.render(spriteBatch);

		spriteBatch.end();
	}

	public Game getGame() {
		return game;
	}

	public OrthographicCamera getCamera() {
		return camera;
	}

	public void setCamera(OrthographicCamera camera) {
		this.camera = camera;
	}
}